home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / tex / td187src.lzh / MTALERTS.I < prev    next >
Text File  |  1991-06-08  |  30KB  |  604 lines

  1. (*#######################################################################
  2.                              M A G I C A L E R T S
  3.   #######################################################################
  4.   V2.01 13.12.90  Jens Pirnay           Korrektur von doAlert
  5.   V2.0  17.10.90  Peter Hellinger       Anpassung an neues MagicSys
  6.   V1.0  29.07.90  Peter Hellinger       TDI-Modula-2
  7.   #######################################################################*)
  8.  
  9. IMPLEMENTATION MODULE mtAlerts;
  10.  
  11. (*------------------------------*)
  12. (*       COMPILERSWITCHES       *)
  13. (*------------------------------*)
  14. (*  TDI-Version:   DEAKTIVIERT  *)
  15. (*------------------------------*)
  16. (* V-  Overflow-Checks          *)
  17. (* R-  Range-Checks             *)
  18. (* S-  Stack-Check              *)
  19. (* N-  NIL-Checks               *)
  20. (* T-  TDI-Compiler vor 3.01    *)
  21. (* Q+  Branch statt Jumps       *)
  22. (*                              *)
  23. (*------------------------------*)
  24. (*  MM2-Version:     AKTIVIERT  *)
  25. (*------------------------------*)
  26. (*$R-   Range-Checks            *)
  27. (*$S-   Stack-Check             *)
  28. (*                              *)
  29. (*------------------------------*)
  30.  
  31.  
  32. FROM SYSTEM     IMPORT  ADDRESS, ADR;
  33. FROM MagicAES   IMPORT  GBOX, GIMAGE, GIBOX, GBUTTON, GSTRING, SELECTABLE, 
  34.                         DEFAULT, Exit, LASTOB, OUTLINED, OBJECT, GrafMkstate;
  35. FROM MagicSys   IMPORT  Nil, Null,
  36.                         Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7,
  37.                         Bit8, Bit9, Bit10, Bit11, Bit12, Bit13, Bit14, Bit15,
  38.                         LOC, Byte, ByteSet, sWORD, sINTEGER, sCARDINAL, sBITSET,
  39.                         lWORD, lINTEGER, lCARDINAL, lBITSET,
  40.                         CastToChar, CastToByte, CastToByteset, CastToInt,
  41.                         CastToCard, CastToBitset, CastToWord, CastToLInt,
  42.                         CastToLCard, CastToLBitset, CastToLWord, CastToAddr;
  43. FROM mtDials    IMPORT  DIALOG, NewDial, CSCREEN, CMOUSE, CPOS, DialCenter, 
  44.                         DSTART, DFINISH, DialForm, DialDraw, DialDo;
  45. FROM MagicStrings  IMPORT  Assign, Length;
  46. IMPORT  MagicAES;
  47.  
  48.  
  49. CONST   cMax =          39;
  50.  
  51. CONST   Box =           0;
  52.         Mover =         1;
  53.         
  54. CONST   Note =          0;
  55.         Wait =          1;
  56.         Stop =          2;
  57.         User =          3;
  58.  
  59. TYPE    tString =       ARRAY [0..cMax] OF CHAR;
  60.         tImage =        ARRAY [0..31] OF lCARDINAL;
  61.  
  62. VAR     Tree:           ARRAY [0..11] OF OBJECT;
  63.         Image:          ARRAY [Note..User] OF tImage;
  64.         AlertText:      ARRAY [0..7] OF tString;
  65.         Icon:           MagicAES.BITBLK;
  66.         Dialog:         DIALOG;
  67.         ChWidth:        sINTEGER;
  68.         ChHeight:       sINTEGER;
  69.         IconColor:      sINTEGER;
  70.  
  71.  
  72. PROCEDURE PrepareAlert;
  73. VAR i: sINTEGER;
  74. BEGIN
  75.  MagicAES.GrafHandle (i, ChWidth, ChHeight, i, i);
  76.  Tree[Box].obNext:= -1;
  77.  Tree[Box].obHead:= 1;
  78.  Tree[Box].obTail:= 0;
  79.  Tree[Box].obType:= GBOX;
  80.  Tree[Box].obFlags:= {};
  81.  Tree[Box].obState:= {OUTLINED};
  82.  Tree[Box].Box.char:= 0C;
  83.  Tree[Box].Box.frame:= 2C;
  84.  Tree[Box].Box.flags:= {Bit15, Bit11};
  85.  Tree[Box].obX:= 0;
  86.  Tree[Box].obY:= 0;
  87.  Tree[Box].obWidth:= 16;
  88.  Tree[Box].obHeight:= 0;
  89.  
  90.  Tree[Mover].obNext:= -1;
  91.  Tree[Mover].obHead:= -1;
  92.  Tree[Mover].obTail:= -1;
  93.  Tree[Mover].obType:= 1119H;
  94.  Tree[Mover].obFlags:= {};
  95.  Tree[Mover].obState:= {OUTLINED};
  96.  Tree[Mover].Box.char:= 0C;
  97.  Tree[Mover].Box.frame:= 1C;
  98.  Tree[Mover].Box.flags:= {Bit15, Bit11};
  99.  Tree[Mover].obX:= 0;
  100.  Tree[Mover].obY:= 0;
  101.  Tree[Mover].obWidth:= 16;
  102.  Tree[Mover].obHeight:= ChHeight;
  103.  MagicAES.ObjcAdd (ADR(Tree), Box, Mover);
  104. END PrepareAlert;
  105.  
  106.  
  107. PROCEDURE doAlert (xp, yp, mode, def: sINTEGER; VAR str: ARRAY OF CHAR): sINTEGER;
  108. VAR i, j, h, c: sINTEGER;
  109.     text, butt: sINTEGER;
  110.     ioff, off:  sINTEGER;
  111.     w, hi, objc:  sINTEGER;
  112.     icon: BOOLEAN;
  113.     b: sBITSET;
  114. BEGIN
  115.  PrepareAlert;
  116.  FOR i:= 0 TO 7 DO  AlertText[i, 0]:= 0C;  END;
  117.  i:= 0;  h:= Length (str);  objc:= 2;  icon:= TRUE;  ioff:= ChWidth * 4;
  118.  IF (i >= h) OR (str[0] # '[') THEN  RETURN -1;  END;
  119.  CASE str[1] OF
  120.   '1': Icon.biData:= ADR (Image[Note]);|
  121.   '2': Icon.biData:= ADR (Image[Wait]);|
  122.   '3': Icon.biData:= ADR (Image[Stop]);|
  123.   '4': Icon.biData:= ADR (Image[User]);|
  124.   ELSE icon:= FALSE;
  125.  END;
  126.  IF icon THEN
  127.   ioff:= (ChWidth * 2) + 32;
  128.   Icon.biWb:= 4; 
  129.   Icon.biHl:= 32;
  130.   Icon.biX:= 0;
  131.   Icon.biY:= 0;
  132.   Icon.biColor:= IconColor; 
  133.   Tree[objc].obNext:= -1;
  134.   Tree[objc].obHead:= -1;
  135.   Tree[objc].obTail:= -1;
  136.   Tree[objc].obType:= GIMAGE;
  137.   Tree[objc].obFlags:= {};
  138.   Tree[objc].obState:= {};
  139.   Tree[objc].ImagePtr:= ADR (Icon);
  140.   Tree[objc].obX:= ChWidth;
  141.   Tree[objc].obY:= ChHeight;
  142.   Tree[objc].obWidth:= 32;
  143.   Tree[objc].obHeight:= 32;
  144.   MagicAES.ObjcAdd (ADR(Tree), Box, objc);
  145.   INC (objc);
  146.  END;
  147.  i:= 2;
  148.  WHILE (str[i] # '[')  DO
  149.   IF i > h THEN  RETURN -1;  END;  INC (i);
  150.  END;
  151.  (* Textzeilen auslesen *)
  152.  text:= 0;  c:= 0;
  153.  LOOP
  154.   j:= 0;  INC (i);
  155.   IF i > h THEN  RETURN -1;  END;
  156.   WHILE (str[i] # '|') AND (str[i] # ']') AND (i <= h) AND (j < cMax) DO
  157.    AlertText[text, j]:= str[i];  INC (i);  INC (j);
  158.   END;
  159.   AlertText [text, j]:= 0C;
  160.   Tree[objc].obNext:= -1;
  161.   Tree[objc].obHead:= -1;
  162.   Tree[objc].obTail:= -1;
  163.   Tree[objc].obType:= GSTRING;
  164.   Tree[objc].obFlags:= {};
  165.   Tree[objc].obState:= {};
  166.   Tree[objc].StringPtr:= ADR (AlertText[text]);
  167.   Tree[objc].obX:= ioff;
  168.   Tree[objc].obY:= ChHeight + (text * ChHeight);
  169.   Tree[objc].obWidth:= ChWidth * j;
  170.   Tree[objc].obHeight:= ChHeight;
  171.   MagicAES.ObjcAdd (ADR(Tree), Box, objc);
  172.   IF Tree[Box].obWidth <= Tree[objc].obWidth THEN
  173.    Tree[Box].obWidth:= ioff + Tree[objc].obWidth + 32;
  174.   END;
  175.   INC (objc);
  176.   INC (text);
  177.   IF (str[i] = ']') OR (text > 4) THEN  EXIT;  END;
  178.  END;
  179.  c:= objc - 1; 
  180.  WHILE (str[i] # '[')  DO
  181.   IF i > h THEN  RETURN -1;  END;  INC (i);
  182.  END;
  183.  (* Buttons auslesen *)
  184.  butt:= 0;  w:= ioff;
  185.  LOOP
  186.   AlertText[butt + text, 0]:= ' ';  j:= 1;  INC (i);
  187.   IF i > h THEN  RETURN -1;  END;
  188.   WHILE (str[i] # '|') AND (str[i] # ']') AND (i <= h) AND (j < cMax) DO
  189.    AlertText[butt + text, j]:= str[i];  INC (i);  INC (j);
  190.   END;
  191.   AlertText [butt + text, j]:= ' ';  INC (j);
  192.   AlertText [butt + text, j]:= 0C;
  193.   Tree[objc].obNext:= -1;
  194.   Tree[objc].obHead:= -1;
  195.   Tree[objc].obTail:= -1;
  196.   Tree[objc].obType:= 0121AH;
  197.   IF butt = def - 1  THEN  Tree[objc].obFlags:= {DEFAULT, SELECTABLE, Exit};
  198.                      ELSE  Tree[objc].obFlags:= {Exit, SELECTABLE};
  199.   END;
  200.   Tree[objc].obState:= {};
  201.   Tree[objc].StringPtr:= ADR (AlertText[butt + text]);
  202.   IF  (Tree[c].obY + (2 * ChHeight)) < (40 + ChHeight)  THEN
  203.    Tree[objc].obY:= 40 + ChHeight;
  204.   ELSE
  205.    Tree[objc].obY:= Tree[c].obY + (2 * ChHeight);
  206.   END;
  207.   Tree[objc].obWidth:= ChWidth * (j - 1);
  208.   (* Buttons auf gleiche Größe bringen *)
  209.   IF butt > 0 THEN
  210.    IF Tree[objc].obWidth < Tree[objc - 1].obWidth THEN
  211.     Tree[objc].obWidth:= Tree[objc - 1].obWidth;
  212.    ELSIF Tree[objc].obWidth > Tree[objc - 1].obWidth THEN
  213.     Tree[objc - 1].obWidth:= Tree[objc].obWidth;
  214.    END;
  215.   END;
  216.   Tree[objc].obHeight:= ChHeight;
  217.   MagicAES.ObjcAdd (ADR(Tree), Box, objc);
  218.   INC (w, Tree[objc].obWidth + (ChWidth * 2));
  219.   INC (objc);
  220.   INC (butt);
  221.   IF (str[i] = ']') OR (butt > 2) THEN  EXIT;  END;
  222.  END;
  223.  IF Tree[Box].obWidth < w THEN
  224.   Tree[Box].obWidth:= w + 48;
  225.  END;
  226.  Tree[Box].obHeight:= Tree[objc - 1].obY + (2 * ChHeight);
  227.  Tree[Mover].obX:= Tree[Box].obWidth - Tree[Mover].obWidth;
  228.  (* Buttons zentrieren *)
  229.  DEC (objc);
  230.  CASE butt OF
  231.   1: Tree[objc].obX:= (Tree[Box].obWidth - Tree[objc].obWidth) DIV 2;
  232.      |
  233.   2: w:= Tree[objc - 1].obWidth + Tree[objc].obWidth;
  234.      w:= ((Tree[Box].obWidth - w) DIV 2) - ChWidth;
  235.      Tree[objc - 1].obX:= w;
  236.      Tree[objc].obX:= w + (ChWidth * 2) + Tree[objc - 1].obWidth;
  237.      |
  238.   3: w:= Tree[objc - 2].obWidth + Tree[objc - 1].obWidth + Tree[objc].obWidth;
  239.      w:= ((Tree[Box].obWidth - w) DIV 2) - (ChWidth * 2);
  240.      Tree[objc - 2].obX:= w;
  241.      Tree[objc - 1].obX:= w + (ChWidth * 2) + Tree[objc - 2].obWidth;